<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');

class Blocks extends Admin_Controller {
	
	function __construct()
	{
		parent::__construct(5);
	}
	
	public function index()
	{
		$vData = array(
			'blocks' => $this->admin->getBlocks()
		);
		
		$data = array(
			'content' => $this->load->view('admin/blocks', $vData, true)
		);
		
		$this->getPage($data);
	}
	
	function add($id = 0)
	{
		if (sizeof($_POST))
		{
			if ($id = $this->admin->saveBlock($_POST))
				redirect('/admin/blocks/add/'.$id);
				else
				redirect('/admin/blocks/');
		}
		
		$vData = array(
			'block' => $this->admin->getBlock($id)
		);
		
		$data = array(
			'content' => $this->load->view('admin/block_add', $vData, true),
			'addJS' => array(
				'/js/markitup/jquery.markitup.js',
				'/js/markitup/sets/default/set.js'
			),
			'addCSS' => array(
				'/js/markitup/skins/markitup/style.css',
				'/js/markitup/sets/default/style.css'
			),
			'adminPage' => true
		);
		
		$this->getPage($data);
	}
}

?>